<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>渲染器-function用法</title>
    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"></link>
</head>
<body>
<table id="example" class="display" style="width:100%">
    <thead>
        <tr>
            <th>产品名称</th>
            <th>创建人</th>
            <th>创建时间</th>
            <th>价格</th>
            <th>成本</th>
        </tr>
    </thead>
    <tbody>
        
    </tbody>
</table>

<script>

    let data = [
            {
            "product": "Toy car",
            "creator": {
                "firstName": "Fiona",
                "lastName": "White"
            },
            "created": "2015-11-01",
            "price": 19.99,
            "cost": 12.53
        }
    ];

    $(document).ready(function () {
        $('#example').DataTable({
            data:data,
            columns:[
                {data:"product"},
                {
                    //他只可以访问已经指定好的值，
                    //data:"creator.firstName"
                    //他可以访问creator下所有的属性
                    data: 'creator',
                    render: 'lastName'
                },
                {data:"created"},
                {data:"price"},
                {data:"cost"}
            ]
        });
    });
</script>
</body>
</html>